// 引入地址、端口、一级路由
import {
  address,
  pathApi
} from "@/api/path";
// 引入 axios
import axios from "axios";
// 查询存货
const queryGoods = (condition, callback) => {
  axios({
    data: {
      idcustomer:condition.idcustomer, //账套名
      DsName:condition.DsName, //账套名
      name: condition.name,  //名称
      status: condition.status||"1",  
      idinventoryclass: condition.idinventoryclass,//分类
      // 分页
      page:condition.page,
      limit:condition.limit,
    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/Inventory/findInventory`
  }).then(function (res) {
    callback(res.data)
  });
}
// 查询客户、结算客户
const queryClient = (condition, callback) => {
  axios({
    data: {
      personId:condition.personId,
      DsName:condition.DsName,
      name: condition.name,
      page: condition.page,
      limit: condition.limit,
    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/Partner/findPartner`
  }).then(function (res) {
    callback(res.data)
  });
}
// 查询部门
const queryOrgs = (condition, callback) => {
  axios({
    data: {
      DsName:condition,
    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/Department/findDepartment`
  }).then(function (res) {
    callback(res.data)
  });
}
// 查询业务员
const queryPerson = (condition, callback) => {
  axios({
    data: {
      iddepartment:condition.id,
      DsName:condition.DsName,

    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/Person/findPerson`
  }).then(function (res) {
    callback(res.data)
  });
}
// 查询单据编号
const queryCode = (condition, callback) => {
  axios({
    data: {
      idvouchertype:43,
      DsName:condition.DsName,

    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/DocSerialNumber/findDocSerialNumber`
  }).then(function (res) {
    callback(res.data)
  });
}
// 提交订单 信息
const submitOrder = (condition, callback) => {
  axios({
    data:condition,
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/SASaleOrder/add`
  }).then(function (res) {
    callback(res.data)
  });
}
// 选存货后获取存货的两个单位
const queryUnits = (condition, callback) => {
  axios({
    data: {
      idunitgroup:condition.idunitgroup,
      DsName:condition.DsName,
    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/unit/findUnitByGroup`
  }).then(function (res) {
    callback(res.data)
  });
}
// 查询存货分类
const queryType = (condition, callback) => {
  axios({
    data: {
      DsName:condition.DsName,
    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/Inventory/findInventoryClass`
  }).then(function (res) {
    callback(res.data)
  });
}
// 查询客户收货地址
const queryAddress = (condition, callback) => {
  axios({
    data: {
      DsName:condition.DsName,
      idpartner:condition.idpartner,
    },
    method: "post",
    headers: {
      "Content-Type": "application/json"
    },
    url: `${address}${pathApi}/Partner/findAddressByPartner`
  }).then(function (res) {
    callback(res.data)
  });
}

export {
  queryGoods,
  queryOrgs,
  queryClient,
  queryPerson,
  queryCode,
  submitOrder,
  queryUnits,
  queryType,
  queryAddress,
}
